package com.zackeus.mvvm.binding.viewadapter.titlebar;

import androidx.databinding.BindingAdapter;

import com.zackeus.mvvm.binding.command.BindingCommand;
import com.zackeus.common.utils.ObjectUtils;
import com.zackeus.mvvm.widget.view.TitleBarView;

/**
*
* @ClassName: ViewAdapter
* @Description: 标题栏适配器
* @Author: zz
* @Date: 2020/12/30 14:51
*/
public class ViewAdapter {

    @BindingAdapter(value = {"onLeftTxtClickCommand"}, requireAll = false)
    public static void titleBarListener(TitleBarView titleBarView, final BindingCommand<Void> onLeftTxtClickCommand) {

        // 左侧标题点击监听
        titleBarView.setOnLeftTxtClickListener(() -> {
            if (ObjectUtils.isNotNull(onLeftTxtClickCommand)) {
                onLeftTxtClickCommand.execute();
            }
        });
    }
}
